package com.haiwen.boot.controller;

import com.haiwen.boot.service.CommentService;
import com.haiwen.boot.vo.ResultMap;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "评论模块")
public class commentController {
    @Autowired
    private CommentService commentService;
    @Autowired
    private ResultMap resultMap;
    @PostMapping(value = "/writeReview")
    @ApiOperation(value = "提交评论功能")
    public ResultMap WriteReview(@RequestParam Integer blogID,
                                 @RequestParam  Integer userID,
                                 @RequestParam  String content){
       return commentService.comment(blogID,userID,content);
    }

    @PostMapping(value = "/ReplyComment")
    @ApiOperation(value = "回复评论功能")
    public ResultMap ReplyComment(@RequestParam @ApiParam("被回复人ID") Integer replyUserID,
                                  @RequestParam  @ApiParam("博客id") Integer blogID,
                                 @RequestParam  @ApiParam("回复人id") Integer userID,
                                 @RequestParam  @ApiParam("父评论id") Integer commentID,
                                 @RequestParam   @ApiParam("回复内容") String content){
        return commentService.ReplyComment(replyUserID,blogID,userID,commentID,content);
    }
    @PostMapping(value = "/ShowComments")
    @ApiOperation(value = "评论展示功能")
    public ResultMap ShowComments(@RequestParam Integer blogID){
        return commentService.ShowComments(blogID);
    }

}
